package net.modul.dept.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;
import net.modul.dept.service.DeptDeleteService;
import net.modul.dept.service.DeptEditorService;
import net.modul.dept.service.DeptFindService;
import net.modul.dept.service.DeptSearchService;
import net.modul.dept.vo.DeptVo;

public class DeptAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private DeptVo bean = new DeptVo();
	private List<DeptVo> list = new ArrayList<DeptVo>();
	
	public String search() throws Exception {
		DeptSearchService service = new DeptSearchService();
		service.setPageBean(pageBean);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}
	
	public String editor() throws Exception {
		DeptEditorService service = new DeptEditorService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}
	
	public String find() throws Exception {
		if(bean.getDept_id() != null) {			
			DeptFindService service = new DeptFindService();
			service.setId(bean.getDept_id());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}
	
	public String delete() throws Exception {
		DeptDeleteService service = new DeptDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}
	
	public DeptVo getBean() {
		return bean;
	}
	public void setBean(DeptVo bean) {
		this.bean = bean;
	}
	public List<DeptVo> getList() {
		return list;
	}
	public void setList(List<DeptVo> list) {
		this.list = list;
	}
}
